<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
        content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>测试</title>

    <style type="text/css">
        button {
            margin: 0 1%;
            width: 46%;
            height: 40px;
            align: center;
            border: 1px solid #e6e6e6;
            background-color: #FBFBFB;
            color: #666666;
            cursor: not-allowed;
            opacity: 1;
        }

        hr {
            height: 1px;
            margin: 10px 0;
            border: 0;
            background-color: #e2e2e2;
            clear: both;
        }

        .tested {
            display: inline-block;
            height: 40px;
            /*line-height: 38px;*/
            padding: 0 18px;
            background-color: #009688;
            color: #fff;
            /*white-space: nowrap;*/
            text-align: center;
            font-size: 14px;
            border: none;
            border-radius: 2px;
            cursor: pointer;
            opacity: .9;
        }
    </style>

    <script src="https://s.url.cn/qqun/qun/qqweb/m/qun/confession/js/vconsole.min.js"></script>
    <script type="text/javascript">
        function show(info) {
            document.getElementById("shows").innerHTML = info;
        }

        function search_device_ok() {
            alert("搜索设备成功");
        }

        function commect_ok() {
            alert("连接设备成功");
        }

        function showResult(result) {
            alert(JSON.stringify(result));
        }

        function showError(result) {
            alert(result.error);
        }

        function c() {
            var p = '{"callback": "function(result) {\
            alert(result.success);\
        }"}';
            var str = JSON.stringify(p);
            alert(str);
            window.CCBBridge.openBluetoothAdapter('{"success": "showResult","fail": "showResult"}');
        }

        function closeBluetooth() {
            window.CCBBridge.closeBluetoothAdapter('{"success": "showResult","fail": "showError"}');
        }

        // 以下为接口测试代码

        // 设备id
        //var deviceId = 'FC:3F:7C:0E:08:D2';
        // var deviceId = '64:76:BA:A3:69:87';
        var deviceId = '64:76:BA:A3:69:87';

        // 服务id
        var serviceId;

        // 特征id
        var characteristicId;

        // 扫描到的蓝牙设备
        var devices;

        // 01．CCBBridge.openBluetoothAdapter
        function openBluetoothAdapter() {

            var callbacks = {
                success: (function (result) {
                    if (deviceId == null) {
                        deviceId = result.devices[0].deviceId;
                        alert(result.devices[0].deviceName);
                    }
                    alert(123);
                }).toString(),
                fail: "showResult"
            };
            window.CCBBridge.openBluetoothAdapter(null, JSON.stringify(callbacks));
        }

        // 02．CCBBridge.closeBluetoothAdapter
        function closeBluetoothAdapter() {
            window.CCBBridge.closeBluetoothAdapter(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 03．CCBBridge.getBluetoothAdapterState
        function getBluetoothAdapterState() {

            window.CCBBridge.getBluetoothAdapterState(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 04．CCBBridge.startBluetoothDevicesDiscovery
        function startBluetoothDevicesDiscovery() {

            var params = {
                services: []
            };

            var callbacks = {
                success: (function (result) {
                    var services = result.services;
                    devices = services;
                    if (typeof devices == 'object') {
                        deviceId = devices[0];
                        alert(deviceId);
                    }
                    alert(JSON.stringify(result));
                }).toString(),
                fail: 'showResult'
            }

            window.CCBBridge.startBluetoothDevicesDiscovery(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 05．CCBBridge.stopBluetoothDevicesDiscovery
        function stopBluetoothDevicesDiscovery() {
            window.CCBBridge.stopBluetoothDevicesDiscovery(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 06．CCBBridge.getBluetoothDevices
        function getBluetoothDevices() {
            var params = {
                services: []
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.getBluetoothDevices(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 07．CCBBridge.getConnectedBluetoothDevices
        function getConnectedBluetoothDevices() {
            var params = {
                services: []
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.getConnectedBluetoothDevices(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 08．CCBBridge.connectBLEDevice
        function connectBLEDevice() {
            var params = {
                deviceId: deviceId
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.connectBLEDevice(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 09．CCBBridge.disconnectBLEDevice
        function disconnectBLEDevice() {
            var params = {
                deviceId: deviceId
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.disconnectBLEDevice(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 10．CCBBridge.writeBLECharacteristicValue
        function writeBLECharacteristicValue() {
            var params = {
                deviceId: deviceId,
                serviceId: '',
                characteristicId: '',
                descriptorId: '',
                value: ''
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.writeBLECharacteristicValue(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 11．CCBBridge.readBLECharacteristicValue
        function readBLECharacteristicValue() {
            var params = {
                deviceId: deviceId,
                serviceId: '',
                characteristicId: '',
                descriptorId: ''
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.readBLECharacteristicValue(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 12．CCBBridge.notifyBLECharacteristicValueChange
        function notifyBLECharacteristicValueChange() {
            var params = {
                deviceId: deviceId,
                serviceId: '',
                characteristicId: '',
                descriptorId: '',
                value: ''
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.notifyBLECharacteristicValueChange(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 13．CCBBridge.getBLEDeviceServices
        function getBLEDeviceServices() {
            var params = {
                deviceId: deviceId
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.getBLEDeviceServices(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 14．CCBBridge.getBLEDeviceCharacteristics
        function getBLEDeviceCharacteristics() {
            var params = {
                deviceId: deviceId,
                serviceId: ''
            };
            var callbacks = {
                success: 'showResult',
                fail: 'showResult'
            }
            window.CCBBridge.getBLEDeviceCharacteristics(JSON.stringify(params), JSON.stringify(callbacks));
        }

        // 15．CCBBridge.onBluetoothDeviceFound
        function onBluetoothDeviceFound() {
            var callbacks = {
                success: (function (result) {
                    if (deviceId == null) {
                        deviceId = result.devices[0].deviceId;
                        alert(result.devices[0].deviceName);
                    }
                }).toString(),
                fail: "showResult"
            };

            window.CCBBridge.onBluetoothDeviceFound(null, JSON.stringify(callbacks));
        }

        // 16．CCBBridge.offBluetoothDeviceFound
        function offBluetoothDeviceFound() {
            window.CCBBridge.offBluetoothDeviceFound(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 17．CCBBridge.onBLECharacteristicValueChange
        function onBLECharacteristicValueChange() {
            window.CCBBridge.onBLECharacteristicValueChange(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 18．CCBBridge.offBLECharacteristicValueChange
        function offBLECharacteristicValueChange() {
            window.CCBBridge.offBLECharacteristicValueChange(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 19．CCBBridge.onBLEConnectionStateChanged
        function onBLEConnectionStateChanged() {
            window.CCBBridge.onBLEConnectionStateChanged(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 20．CCBBridge.offBLEConnectionStateChanged
        function offBLEConnectionStateChanged() {
            window.CCBBridge.offBLEConnectionStateChanged(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 21．CCBBridge.onBluetoothAdapterStateChange
        function onBluetoothAdapterStateChange() {
            window.CCBBridge.onBluetoothAdapterStateChange(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 22．CCBBridge.offBluetoothAdapterStateChange
        function offBluetoothAdapterStateChange() {
            window.CCBBridge.offBluetoothAdapterStateChange(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 23．CCBBridge.getLocation
        function getLocation() {
            window.CCBBridge.getLocation(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 24．CCBBridge.httpRequest
        function httpRequest() {
            var params = {
                url: 'http://www.baidu.com',
                headers: {},
                method: 'GET',
                data: 'a=123&b=321',
                timeout: 30000,
                dataType: 'json'
            };
            window.CCBBridge.httpRequest(JSON.stringify(params), '{"success": "showResult","fail": "showResult"}');
        }

        // 25．CCBBridge.setStorage
        function setStorage() {
            window.CCBBridge.setStorage('{"key": "test_key", "data": "test data"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 26．CCBBridge.setStorageSync
        function setStorageSync() {
            window.CCBBridge.setStorageSync('{"key": "test_key", "data": "test data"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 27．CCBBridge.getStorage
        function getStorage() {
            window.CCBBridge.getStorage('{"key": "test_key"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 28．CCBBridge.getStorageSync
        function getStorageSync() {
            window.CCBBridge.getStorageSync('{"key": "test_key"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 29．CCBBridge.removeStorage
        function removeStorage() {
            window.CCBBridge.removeStorage('{"key": "test_key"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 30．CCBBridge.removeStorageSync
        function removeStorageSync() {
            window.CCBBridge.removeStorageSync('{"key": "test_key"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 31．CCBBridge.getSystemInfo
        function getSystemInfo() {
            window.CCBBridge.getSystemInfo(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 32．CCBBridge.getNetworkType
        function getNetworkType() {
            window.CCBBridge.getNetworkType(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 33．CCBBridge.scan
        function scan() {
            window.CCBBridge.scan('{"type": ""}', '{"success": "showResult","fail": "showResult"}');
        }

        // 34．CCBBridge.openTorch
        function openTorch() {
            window.CCBBridge.openTorch(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 35．CCBBridge.closeTorch
        function closeTorch() {
            window.CCBBridge.closeTorch(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 36．CCBBridge.makePhoneCall
        function makePhoneCall() {
            window.CCBBridge.makePhoneCall('{"number": "13800138000"}', '{"success": "showResult","fail": "showResult"}');
        }

        // 37．CCBBridge.getServerTime
        function getServerTime() {
            window.CCBBridge.getServerTime(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 38．CCBBridge.captureScreen
        function captureScreen() {
            window.CCBBridge.captureScreen(null, '{"success": "showResult","fail": "showResult"}');
        }

        // 39．登录
        function ccbLogin() {
            // window.location.href = "ccbnativefunction://ccblogin";
            CCBBridge.ccbLogin(null, '{"success": "showResult","fail": "showResult"}');
        }
        // 40．登录
        function getUserInfo() {
            // window.location.href = "ccbnativefunction://ccbuserinfo";
            CCBBridge.ccbUserInfo(null, '{"success": "showResult","fail": "showResult"}');
        }
        // 41.发送手机请求
        function sendMbsRequest() {
            var req = {
                method: 'POST',
                channel: "MBS", // MBS(手机), EBS(网银), WWW(网站)
                path: '/cmccb/servlet/ccbNewUIClient',
                txCode: "NP0001",
                showLoading: true,
                params: {
                    type: '0'
                }
            };
            CCBBridge.ccbSendRequest(JSON.stringify(req), "showResult");
        }
        // 41.1发送网银请求
        function sendEbsRequest() {
            CCBBridge.ccbUserInfo(null, "afterGetUserInfoToEbs");
        }
        // 41.2发送网站请求
        function sendWwwRequest() {

            //CCBBridge.ccbUserInfo(null, "afterGetUserInfo");
            var req = {
                channel: "WWW", // MBS(手机), EBS(网银), WWW(网站)
                path: '/tran/WCCMainPlatV5',
                txCode: "ZX2005",
                params: {}
            };
            CCBBridge.ccbSendRequest(JSON.stringify(req), "showResult");
        }

        function afterGetUserInfoToEbs(user) {
            var req = {
                method: "POST",
                channel: "EBS", // MBS(手机), EBS(网银), WWW(网站)
                // http://128.128.97.200:8601/CCBIS/B2CMainPlat_02_MB
                path: '/CCBIS/B2CMainPlat_13_MB',
                txCode: "SJXE05",
                showLoading: true,
                params: {
                    Cst_ID: user.ECIFCust_No,
                }
            };
            CCBBridge.ccbSendRequest(JSON.stringify(req), "showResult");
        }

        // 42.启动功能
        function start() {
            // 测试扫一扫
            // window.location.href = "ccbnativefunction://ccbcallcenter?funcid=15002001";'PandaAccJumpSucUrl=' + encodeURIComponent('https://lsjr.ccb.com/dl/1jnRS')
            var params = {
                funcid: '12030018',
                param: '123232323243666666666666'
            };
            CCBBridge.ccbCallCenter(JSON.stringify(params), '{"success": "showResult","fail": "showResult"}');
        }


        // 43.获取请求公共字段
        function getRequestCommonInfo() {
            CCBBridge.ccbRequestCommonInfo(null, 'showResult');
        }

        function nativeCallBack(result) {
            alert(JSON.stringify(result));
        }

        // 43.政务服务测试
        function resGovernmentService() {
            window.console.info("政务服务测试");
            CCBBridge.resGovernmentService(null, 'showResult');
        }
         // 43.政务服务回调
        function resGovernmentServiceCallBack() {
            CCBBridge.resGovernmentService(null, 'showResult');
        }
    </script>

</head>

<body>

    <button class="tested" onClick="ccbLogin();">登录</button>
    <button class="tested" onClick="getUserInfo();">获取绑定信息</button>

    <hr>
    <button class="tested" onClick="sendMbsRequest();">发送手机请求</button>
    <button class="tested" onClick="sendEbsRequest();">发送网银请求</button>

    <hr>
    <button class="tested" onClick="sendWwwRequest();">发送网站请求</button>
    <!--<button class="tested" onClick="start();">打开第二个Html</button>-->

    <!--<button class="tested" onClick="start();">打开第二个Html</button>-->
    <a href="F:\JHVersion\CCBClient_V5.6.5.002\Main_CCBClient\assets\test.html">打开第二个Html</a>

    <button class="tested" onClick="start();">跳转功能id</button>

    <a href="bBCCLObSE://close">关闭按钮</a>
	<a href="mbspay://feepay?txflag=5&bill_flag=1&bill_item=02015&Payinwarr_ID=rtyuiuyt5674567&CnptIP_Nm=MingMIMing&Pcsg_Tm=2021-06-17 08:51:00&Displ_Unit_Nm=QingDaoGongan&Atch_Adr=QingDaoJiandao&Fine_Amt=100.00&LatePymtAmt=50.00&ToPy_TAmt=150.00&MblPh_No=11034103455">异地交罚</a>
	<a href="mbspay://feepay?payrequrl=http://feepay.com&payparam=txflag=5&bill_flag=1&bill_item=02015&Payinwarr_ID=rtyuiuyt5674567&CnptIP_Nm=MingMIMing&Pcsg_Tm=2021-06-17 08:51:00&Displ_Unit_Nm=QingDaoGongan&Atch_Adr=QingDaoJiandao&Fine_Amt=100.00&LatePymtAmt=50.00&ToPy_TAmt=150.00&MblPh_No=11034103455">异地交罚2</a>

    <hr>
    <button class="tested" onClick="getRequestCommonInfo();">获取报文头与报文体公共信息</button>

    <hr>
    <button class="tested" onClick="resGovernmentService();">政务服务测试</button>

    <script>
        function sbdd() {
            var uuid = window.BlInterface.startBluetoothDevicesDiscovery("50:8C:B1:62:AB");

        }

        function connect() {

            var uuid = window.BlInterface.connectBLEDevice("15,18,13,13,13,78,77,41,70,36,53,11,48,85,87,34", "0,9,8,7,5,7");
        }
    </script>

</body>

</html>